<template>
	<div class="w-full rounded-lg bg-white flex flex-col">
		<div class="flex justify-end px-5 pt-5">
			<button class="btn btn-lan" @click="router.push('list')">返回列表</button>
		</div>
		<div v-if="article.title" class="px-5 pb-5 overflow-y-auto">
			<div class="font-medium text-xl text-center">{{ article.title }}</div>
			<div class="py-4 flex justify-center text-slate-400 space-x-4 border-b border-dashed border-hui-100">
				<div><span>发布时间：</span> {{ article.create_time }}</div>
				<div><span>发布人：</span> {{ article.admin_id_name }}</div>
			</div>
			<div v-html="article.content" class="text-lg indent-8 font-thin leading-8 mt-3"></div>
		</div>
	</div>
</template>

<script setup>
	import { postData } from '@/common/base'
	import { router } from '@/router'
	import { onMounted, ref } from 'vue'

	const article = ref({})
	const getContent = async () => {
		try {
			const res = await postData('article/read', { id: router.currentRoute.value.query.id })
			if (res.code) {
				const { data } = res
				article.value = data
			}
		} catch (error) {}
	}
	onMounted(() => {
		getContent()
	})
</script>
